const app = getApp()
// 在页面中定义插屏广告
let interstitialAd = null
import {
  myRequesy,
  homeRequesy
} from '../../request/api.js'
Page({

  /**
   * 页面的初始数据
   */
  data: {
    // 头部选项卡数组
    head: [{
        name: "关注",
        status: false,
        id: 0
      },
      {
        name: "推荐",
        status: true,
        id: 1
      }
    ],
    Dynamiclist: [], //用户动态推荐列表
    DynamicNextPage: null, //判断推荐列表是否有下一页数据
    DynamicPageNum: 1, //推荐列表页码值
    attentionList: [], //用户动态关注列表
    attenNextPage: null, //判断关注列表是否有下一页数据
    attenPageNum: 1, //关注列表页码值
    CecommendUserslist: [], //推荐关注列表
    absSipwerList: [], //保存广告列表
    Hireveal: false, //转发显示底部弹窗事件
    follreveal: false, //关注弹窗显示隐藏控制
    show: true, //控制是否显示推荐关注
    activeIndex: null,
    dynamicId: null,
    whether: false,
    Atttitle: false,
    stateList: [], //保存状态
    Refresh: false,
    shut: true, //控制新人专享

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.getDynamiclist();
    this.getadsList()
    this.getVisit()


    // 在页面onLoad回调事件中创建插屏广告实例
    if (wx.createInterstitialAd) {
      interstitialAd = wx.createInterstitialAd({
        adUnitId: 'adunit-bfaf674205f6b997'
      })
      interstitialAd.onLoad(() => {})
      interstitialAd.onError((err) => {})
      interstitialAd.onClose(() => {})
    }

    // 在适合的场景显示插屏广告
    if (interstitialAd) {
      interstitialAd.show().catch((err) => {
        console.error(err)
      })
    }
  },

  // 用户访问时调用
  getVisit() {
    myRequesy({
      url: 'user/view-index',
      method: 'POST',
    }).then(res => {})
  },

  //头部选项卡事件
  btnCut(e) {
    console.log(e);

    wx.pageScrollTo({ //回到顶部
      scrollTop: 0,
      duration: 300
    })
    if (this.data.Refresh) {
      wx.startPullDownRefresh() //下拉加载
    }


    let index = e.currentTarget.dataset.index
    let head = this.data.head
    head.forEach((item, i) => index === i ? item.status = true : item.status = false)
    this.setData({
      head,
      DynamicPageNum: 1,
      attenPageNum: 1
    })
    let token = wx.getStorageSync('userInfo').token
    if (index === 1) {
      this.getDynamiclist()
      this.setData({
        show: true,
      })
    } else {
      if (token) {
        this.getAttentionlist()
      } else {
        this.getRecommendLogin()
      }
    }



  },
  // 用户动态转发事件
  btnForward(e) {
    let token = wx.getStorageSync('userInfo').token
    if (!token) {
      this.getRestLogin()
      return
    }
    wx.hideTabBar()
    if (e.currentTarget.dataset.state === 1) { //推荐
      let arr = this.data.Dynamiclist[e.currentTarget.dataset.index].img_list
      this.setData({
        Hireveal: true,
        arr,
        nickName: e.currentTarget.dataset.name,
        avatarUrl: e.currentTarget.dataset.url,
        qrcodeId: e.currentTarget.dataset.id,
        State: e.currentTarget.dataset.state,
        Index: e.currentTarget.dataset.index,
        Isown: e.currentTarget.dataset.isown
      })
      return
    } //关注
    let arr = this.data.attentionList[e.currentTarget.dataset.index].img_list
    this.setData({
      Hireveal: true,
      arr,
      nickName: e.currentTarget.dataset.name,
      avatarUrl: e.currentTarget.dataset.url,
      qrcodeId: e.currentTarget.dataset.id,
      State: e.currentTarget.dataset.state,
      Index: e.currentTarget.dataset.index,
      Isown: e.currentTarget.dataset.isown
    })

  },



  //用户关注/已关注事件
  btnpay(e) {
    this.setData({
      userId: e.currentTarget.dataset.id,
      status: e.currentTarget.dataset.status,
      dynamicId: e.currentTarget.dataset.id1,
      index1: e.currentTarget.dataset.index,
    })
    let {
      Dynamiclist
    } = this.data
    let that = this
    let token = wx.getStorageSync('userInfo').token
    if (token) {
      //用户关注
      if (that.data.status === 0) {
        myRequesy({
          url: 'follow/add',
          method: 'POST',
          data: {
            user_id: that.data.userId
          }
        }).then(res => {
          if (res.data.code === 0 || res.data.code === 3003) {
            wx.showToast({
              title: '关注成功',
            })
            that.setData({
              follreveal: false,
            })
            myRequesy({
              url: 'dynamic/detail',
              data: {
                dynamic_id: that.data.dynamicId
              }
            }).then(res => {
              if (res.data.code === 0) {
                //根据当前点击的动态 修改动态
                Dynamiclist[that.data.index1] = res.data.data
                that.setData({
                  Dynamiclist
                })
                //判断data数据中用户id 修改所有此用户的关注状态
                Dynamiclist.forEach(item => {
                  if (item.user.id == res.data.data.user.id) {
                    item.follow_state = res.data.data.follow_state
                  }
                })
                that.setData({
                  Dynamiclist
                })
              }
            })
          }
        })
      } else {
        that.setData({
          follreveal: true,
        })
      }
    } else {
      that.getRestLogin()
    }
  },

  // 用户取消关注
  headleConfirm() {
    let that = this
    let {
      Dynamiclist
    } = this.data
    myRequesy({
      url: 'follow/take-off',
      method: 'POST',
      data: {
        user_id: that.data.userId
      }
    }).then(res => {
      if (res.data.code === 0) {
        wx.showToast({
          title: '已取消关注',
        })
        that.setData({
          follreveal: false,
        })
        myRequesy({
          url: 'dynamic/detail',
          data: {
            dynamic_id: that.data.dynamicId
          }
        }).then(res => {
          console.log(res);
          if (res.data.code === 0) {
            //根据当前点击的动态 修改动态
            Dynamiclist[that.data.index1] = res.data.data
            that.setData({
              Dynamiclist
            })
            //判断data数据中用户id 修改所有此用户的关注状态
            Dynamiclist.forEach(item => {
              if (item.user.id == res.data.data.user.id) {
                item.follow_state = res.data.data.follow_state
              }
            })
            that.setData({
              Dynamiclist
            })
          }
        })
      }
    })
  },


  // 用户取消转发/遮罩层事件
  btnCancel() {
    this.setData({
      follreveal: false,
      Hireveal: false
    })
    wx.showTabBar()
  },

  //点击用户头像跳转到用户动态页
  navDetail(e) {
    let token = wx.getStorageSync('userInfo').token
    if (!token) {
      this.getLAynogin(e)
      return
    }
    wx.navigateTo({
      url: '/pages/dynamic/dynamic?&id=' + e.currentTarget.dataset.id,
    })

  },

  //  跳转到动态发布页
  navRelease() {
    let token = wx.getStorageSync('userInfo').token
    if (!token) {
      this.getRestLogin()
      return
    }
    wx.navigateTo({
      url: '/pages/release/release',
    })
  },


  //获取广告数据列表
  getadsList() {
    myRequesy({
      url: 'ads',
    }).then(res => {
      if (res.data.code === 0) {
        this.setData({
          absSipwerList: res.data.data
        })
      }
    })
  },

  // 获取用户信息保存到本地/评论
  getLogin(e) {
    let that = this
    wx.getUserProfile({
      desc: '获取您的用户名和头像',
      success(res1) {
        wx.login({
          success(res2) {
            console.log(res2);
            let userData = {
              code: res2.code,
              nickName: res1.userInfo.nickName,
              avatarUrl: res1.userInfo.avatarUrl
            }
            myRequesy({
              url: 'Login',
              data: userData,
              method: 'POST'
            }).then(result => {
              wx.setStorage({
                data: result.data.data,
                key: 'userInfo',
                success() {
                  wx.navigateTo({
                    url: '/pages/details/details?id=' + e.currentTarget.dataset.id,
                  })
                }
              })
            })
          }
        })
      }
    })
  },

  // 获取用户信息保存到本地/关注/点赞
  getRestLogin() {
    let that = this
    wx.getUserProfile({
      desc: '获取您的用户名和头像',
      success(res1) {
        wx.login({
          success(res2) {
            console.log(res2);
            let userData = {
              code: res2.code,
              nickName: res1.userInfo.nickName,
              avatarUrl: res1.userInfo.avatarUrl
            }
            myRequesy({
              url: 'Login',
              data: userData,
              method: 'POST'
            }).then(result => {
              wx.setStorage({
                data: result.data.data,
                key: 'userInfo',
                success() {
                  that.getDynamiclist()
                }
              })

            })
          }
        })
      }
    })
  },


  //点击用户授权的回调
  getRecommendLogin() {
    let that = this
    wx.getUserProfile({
      desc: '获取您的用户名和头像',
      success(res1) {
        console.log(res1);
        wx.login({
          success(res2) {
            console.log(res2);
            let userData = {
              code: res2.code,
              nickName: res1.userInfo.nickName,
              avatarUrl: res1.userInfo.avatarUrl
            }
            myRequesy({
              url: 'Login',
              data: userData,
              method: 'POST'
            }).then(result => {
              wx.setStorage({
                data: result.data.data,
                key: 'userInfo',
                success() {
                  that.getAttentionlist()
                  console.log("成功");
                }
              })
            })
          }
        })
      }
    })
  },


  // 获取用户动态推荐列表 
  getDynamiclist() {
    let that = this
    // 判断是否有token如果有就携带token否则就不携带
    let token = wx.getStorageSync('userInfo').token
    let header = {
      'content-type': 'application/json'
    };
    if (token) {
      header['Authorization'] = wx.getStorageSync('userInfo').token
    }
    homeRequesy({
      url: 'index/recommend/dynamics',
      data: {
        page: that.data.DynamicPageNum
      },
      header
    }).then(res => {
      if (res.data.code === 0) {
        let obj = {}
        //数组对象根据Id去重
        let Dynamiclist = res.data.data.reduce((cur, next) => {
          obj[next.id] ? "" : obj[next.id] = true && cur.push(next);
          return cur;
        }, [])
        that.setData({
          Dynamiclist,
          DynamicNextPage: res.data.next_url
        })
      }

    })
  },


  // 获取用户推荐列表下一页数据
  getDynamicNextlist() {
    let that = this
    if (that.data.DynamicNextPage !== null) {
      that.data.DynamicPageNum += 1
      // 判断是否有token如果有就携带token否则就不携带
      let token = wx.getStorageSync('userInfo').token
      let header = {
        'content-type': 'application/json'
      };
      if (token) {
        header['Authorization'] = wx.getStorageSync('userInfo').token
      }
      homeRequesy({
        url: 'index/recommend/dynamics',
        data: {
          page: that.data.DynamicPageNum
        },
        header
      }).then(res => {
        if (res.data.code === 0) {
          //获取下一页数据
          let Dynamiclist = [...that.data.Dynamiclist, ...res.data.data]
          let obj = {}
          //数组对象根据Id去重
          let arrs = Dynamiclist.reduce((cur, next) => {
            obj[next.id] ? "" : obj[next.id] = true && cur.push(next);
            return cur;
          }, [])
          that.setData({
            Dynamiclist: arrs,
            DynamicNextPage: res.data.next_url
          })
        }

      })
    }

  },


  // 获取用户信息保存到本地/头像
  getLAynogin(e) {
    let that = this
    wx.getUserProfile({
      desc: '获取您的用户名和头像',
      success(res1) {
        console.log(res1);
        wx.login({
          success(res2) {
            console.log(res2);
            let userData = {
              code: res2.code,
              nickName: res1.userInfo.nickName,
              avatarUrl: res1.userInfo.avatarUrl
            }
            myRequesy({
              url: 'Login',
              data: userData,
              method: 'POST'
            }).then(result => {
              wx.setStorage({
                data: result.data.data,
                key: 'userInfo',
                success() {
                  wx.navigateTo({
                    url: '/pages/dynamic/dynamic?id=' + e.currentTarget.dataset.id,
                  })
                }

              })

            })
          }
        })
      }
    })
  },

  // 获取用户关注列表
  getAttentionlist() {
    let that = this
    myRequesy({
      url: 'index/follow/dynamics',
      data: {
        page: that.data.attenPageNum
      }
    }).then(res => {
      if (res.data.code === 0 && res.data.data == null) {
        that.getCecommendUserslist()
        that.setData({
          show: false,
          Atttitle: true
        })
      } else if (res.data.code === 3006) {
        that.getCecommendUserslist()
        that.setData({
          show: false,
          Atttitle: false
        })
      } else {
        this.setData({
          attentionList: res.data.data,
          attenNextPage: res.data.next_url,
          show: true
        })
      }

    })
  },

  // 获取用户关注列表下一页数据
  getAttentionNextlist() {
    let that = this
    if (that.data.attenNextPage !== null) {
      that.data.attenPageNum += 1
      myRequesy({
        url: 'index/follow/dynamics',
        data: {
          page: that.data.attenPageNum
        }
      }).then(res => {
        if (res.data.data == null) {
          that.getCecommendUserslist()
          that.setData({
            show: false,
          })
        } else {
          this.setData({
            attentionList: [...that.data.attentionList, ...res.data.data],
            attenNextPage: res.data.next_url,
            show: true
          })
        }

      })
    }
  },


  //点击评论跳转到动态详情页
  navComm(e) {
    let token = wx.getStorageSync('userInfo').token
    if (token) {
      let activeIndex = this.data.activeIndex
      let id = e.currentTarget.dataset.id;
      this.setData({
        activeIndex: e.currentTarget.dataset.index,
        dynamicId: id
      })
      wx.navigateTo({
        url: '/pages/details/details?status=true&id=' + id,
      })
      return
    }
    this.getLogin(e)

  },

  // 点击空白区域跳转到动态详情
  headleNavComm(e) {
    let token = wx.getStorageSync('userInfo').token
    if (token) {
      let id = e.currentTarget.dataset.id;
      let activeIndex = this.data.activeIndex
      this.setData({
        activeIndex: e.currentTarget.dataset.index,
        dynamicId: id
      })
      wx.navigateTo({
        url: '/pages/details/details?&id=' + id,
      })
      return
    }
    this.getLogin(e)
  },


  //获取推荐关注列表
  getCecommendUserslist() {
    let that = this
    myRequesy({
      url: 'follow/recommend-users'
    }).then(res => {
      res.data.data.forEach(item => {
        item.status = true
      })
      that.setData({
        CecommendUserslist: res.data.data,
        len: res.data.data.length
      })
    })


  },


  //勾选和不勾选事件
  headleSlse(e) {
    let {
      index
    } = e.detail.currentTarget.dataset
    let {
      CecommendUserslist,
      len
    } = this.data
    CecommendUserslist[index].status = !CecommendUserslist[index].status
    len = CecommendUserslist.filter(item => item.status == true).length
    this.setData({
      CecommendUserslist,
      len
    })


  },

  // 用户一键关注
  headleOneKey() {
    let {
      CecommendUserslist
    } = this.data
    let that = this
    CecommendUserslist.forEach(item => {
      if (item.status == true) {
        myRequesy({
          url: 'follow/add',
          method: 'POST',
          data: {
            user_id: item.id
          }
        }).then(res => {
          if (res.data.code === 0) {
            that.setData({
              show: true
            })
            that.getAttentionlist()
          }

        })
      }
    })
  },


  //动态推荐点赞
  headlePraise(e) {
    let {
      id,
      status,
      index
    } = e.currentTarget.dataset
    let {
      Dynamiclist
    } = this.data
    let that = this
    let token = wx.getStorageSync('userInfo').token
    if (token) {
      if (status) {
        myRequesy({
          url: 'dynamic-likes/delete',
          method: 'POST',
          data: {
            dynamic_id: id
          }
        }).then(res => {
          if (res.data.code === 0) {
            myRequesy({
              url: 'dynamic/detail',
              data: {
                dynamic_id: id
              }
            }).then(res => {
              if (res.data.code === 0) {
                Dynamiclist[index] = res.data.data
                that.setData({
                  Dynamiclist
                })
              }
            })
          }
        })
      } else {
        myRequesy({
          url: 'dynamic-likes/add',
          method: 'POST',
          data: {
            dynamic_id: id
          }
        }).then(res => {
          if (res.data.code === 0) {
            myRequesy({
              url: 'dynamic/detail',
              data: {
                dynamic_id: id
              }
            }).then(res => {
              if (res.data.code === 0) {
                Dynamiclist[index] = res.data.data
                that.setData({
                  Dynamiclist
                })
              }
            })
          }
        })
      }
    } else {
      this.getRestLogin()
    }
  },



  //用户修改后的状态
  getSlist() {
    let arr = JSON.parse(wx.getStorageSync('stateList'))
    let {
      Dynamiclist,
      attentionList
    } = this.data
    //判断缓存中的数据Id是否和data中的数据Id一样 点赞 评论 
    arr.find(item => {
      Dynamiclist.find(item1 => { //推荐列表
        if (item.id.toString() == item1.id.toString()) {
          item1.is_likes = item.is_likes
          item1.likes_count = item.likes_count
          item1.comments_count = item.comments
        }
      })
      attentionList.find(item2 => { //关注列表
        if (item.id.toString() == item2.id.toString()) {
          item2.is_likes = item.is_likes
          item2.likes_count = item.likes_count
          item2.comments_count = item.comments
        }
      })

    })
    this.setData({
      Dynamiclist,
      attentionList
    })
  },

  // 关注状态
  attentionId() {
    let that = this
    let listId = wx.getStorageSync('listId')
    let {
      Dynamiclist
    } = that.data
    Dynamiclist.find(item => { //判断关注
      listId.find(item1 => {
        if (item.user.id == item1.id) {
          item.follow_state = item1.follow_state
        }
      })
    })
    that.setData({
      Dynamiclist
    })
  },

  //动态关注点赞
  headlePraiseZan(e) {
    let {
      id,
      status,
      index
    } = e.currentTarget.dataset
    let {
      attentionList
    } = this.data
    let that = this
    let token = wx.getStorageSync('userInfo').token
    if (token) {
      if (status) {
        myRequesy({
          url: 'dynamic-likes/delete',
          method: 'POST',
          data: {
            dynamic_id: id
          }
        }).then(res => {
          if (res.data.code === 0) {
            myRequesy({
              url: 'dynamic/detail',
              data: {
                dynamic_id: id
              }
            }).then(res => {
              if (res.data.code === 0) {
                attentionList[index] = res.data.data
                that.setData({
                  attentionList
                })
              }
            })
          }
        })
      } else {
        myRequesy({
          url: 'dynamic-likes/add',
          method: 'POST',
          data: {
            dynamic_id: id
          }
        }).then(res => {
          if (res.data.code === 0) {
            myRequesy({
              url: 'dynamic/detail',
              data: {
                dynamic_id: id
              }
            }).then(res => {
              if (res.data.code === 0) {
                attentionList[index] = res.data.data
                that.setData({
                  attentionList
                })
              }
            })
          }
        })
      }
    } else {
      this.getRestLogin()
    }
  },



  // 预览动态图片
  btnPreview(e) {
    console.log(e);
    let current = e.currentTarget.dataset.item1
    let urls = e.currentTarget.dataset.item
    wx.previewImage({
      current,
      urls
    })
  },


  // 跳转到标签页
  btnNavTag(e) {
    let token = wx.getStorageSync('userInfo').token
    if (!token) {
      this.getRestLogin()
      return
    }
    if (e.currentTarget.dataset.status) {
      wx.navigateTo({
        url: '/pages/hddetails/hddetails?id=' + e.currentTarget.dataset.id,
      })
    } else {
      wx.navigateTo({
        url: '/pages/tag/tag?id=' + e.currentTarget.dataset.id,
      })
    }

  },

  // 跳转到海报页
  headleTransmit() {
    wx.navigateTo({
      url: '/pages/transmit/transmit?arr=' + JSON.stringify(this.data.arr) + '&nickName=' + this.data.nickName + '&avatarUrl=' + this.data.avatarUrl + '&qrcodeId=' + this.data.qrcodeId
    })
  },
  // 跳转到新人用户页
  headleTask() {
    let token = wx.getStorageSync('userInfo').token
    if (token) {
      wx.navigateTo({
        url: '/pages/mission/mission',
      })
      return
    }
    this.getRestLogin()

  },


  //跳转到对应的小程序或web-view
  headleNavProgram(e) {
    let {
      appid,
      state,
      path,
      url
    } = e.currentTarget.dataset.item
    if (state == 0) {
      wx.navigateToMiniProgram({
        appId: appid,
        path,
      })
      return
    }
    let data = encodeURIComponent(url) //编码
    wx.navigateTo({
      url: '/pages/webView/webView?url=' + data,
    })

  },


  // 第一张轮播图跳转到大赛页
  headleNavMega() {
    let token = wx.getStorageSync('userInfo').token
    if (token) {
      wx.navigateTo({
        url: '/pages/megagame/megagame',
      })
      return
    }
    this.getRestLogin()
  },
  // 第二张轮播图跳转到新人任务页
  headleNavMiss() {
    let token = wx.getStorageSync('userInfo').token
    if (token) {
      wx.navigateTo({
        url: '/pages/mission/mission',
      })
      return
    }
    this.getRestLogin()
  },




  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    //用户点击操作点赞 评论
    if (JSON.parse(wx.getStorageSync('stateList') !== '')) {
      this.getSlist()
      setTimeout(() => {
        wx.removeStorageSync('stateList')
      }, 1500)
    }
    //判断缓存中的数据Id是否和data中的数据Id一样 删除对应的 
    if (JSON.parse(wx.getStorageSync('deleteId') !== '')) {
      let that = this
      let {
        Dynamiclist
      } = that.data
      let deleteId = JSON.parse(wx.getStorageSync('deleteId'))
      // 循环++
      for (let i = 0; i < Dynamiclist.length; i++) {
        deleteId.forEach(item => {
          if (Dynamiclist[i].id.toString() == item.toString()) {
            Dynamiclist.splice(i, 1);
            i--;
          }
        })

      };
      // 循环--
      // for (let i = Dynamiclist.length - 1; i >= 0; i--) {
      //   deleteId.forEach(item => {
      //     if (Dynamiclist[i].id.toString() == item.toString()) {
      //       Dynamiclist.splice(i, 1)
      //     }
      //   })
      // }
      that.setData({
        Dynamiclist
      })
      setTimeout(() => {
        wx.removeStorageSync('deleteId')
      }, 1500)
    }

    // 用户关注
    if (wx.getStorageSync('listId')) {
      this.attentionId()
      setTimeout(() => {
        wx.removeStorageSync('listId')
      }, 1500)
    }


    //第一次刷新页面
    if (wx.getStorageSync('state')) {
      this.getDynamiclist()
    }
    setTimeout(() => {
      wx.removeStorageSync('state')
    }, 1500)

    // 新人专享
    if (wx.getStorageSync('conceal')) {
      this.setData({
        shut: false
      })
    }

  },

  onPageScroll: function (res) {
    if (res.scrollTop > 300) {
      this.setData({
        Refresh: true
      })
      return
    }
    this.setData({
      Refresh: false
    })
  },
  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },



  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
    this.setData({
      DynamicPageNum: 1,
      attenPageNum: 1
    })
    if (this.data.head[0].status) {
      this.getAttentionlist()
    } else {
      this.getDynamiclist()
    }
    setTimeout(() => {
      wx.stopPullDownRefresh();
    }, 1300)
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    if (this.data.head[0].status) {
      this.getAttentionNextlist() //关注列表下一页数据
    } else {
      this.getDynamicNextlist() //推荐列表下一页数据
    }


  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function (res) {
    let that = this
    let {
      Index,
      Dynamiclist,
      attentionList,
      State,
      qrcodeId
    } = that.data

    if (res.from === "menu") {
      return {
        title: "一个记录美好的小程序，数千万摄影爱好者的聚集地",
        path: "/pages/index/index"
      }
    } else if (that.data.Isown) {
      return {
        title: "我发布了一组作品，快来帮我点个赞",
        path: "/pages/details/details?id=" + qrcodeId,
        imageUrl: Dynamiclist[Index].img_list[0]
      }
    } else {
      return {
        title: "这组摄影作品很精彩，快来一起围观",
        path: "/pages/details/details?id=" + qrcodeId,
        imageUrl: State === 1 ? Dynamiclist[Index].img_list[0] : attentionList[Index].img_list[0]
      }
    }


  },

  onShareTimeline: function (res) {
    return {
      title: "青年摄影 ",
      query: "/pages/index/index",
      imageUrl: "/static/img/111.png"
    }
  }
})